#include<bits/stdc++.h>
using namespace std;
int n,m;
typedef long long ll;
ll k,l;
string a;
//for循环
ll getlast(){
    ll ans=1;
    for(int i=0;i<n;i++){
        if(a[i]=='y') ans=2*ans;
        else ans=(2*ans)+1;
    }        
    return ans;
}
//递归
ll dfs(ll res,int pos){
   if(pos==n)
      return res;
   if(a[pos]=='y')
        dfs(2*res,pos+1);
   else
        dfs(2*res+1,pos+1);
   
}
int main(){
    std::ios::sync_with_stdio(false);
    cin>>n>>m;
    //结论有2^n个 树的深度为n+1 根节点深度设为1
    k=pow(2,n);
    while(m){
        cin>>a;
        l=dfs(1,0);
        cout<<l-k+1<<"\n";
        m--;
    }

    return 0;
}